<?php
    class ClipController extends Controller
    {    
        public function actionIndex(){
            $this->layout = "clip";
            $this->linkCanoncical = Url::createUrl('home/index');
            $this->metaTitle = "Kiem tien tren mang, kiem tien that tren mang, viec lam online";
            $this->metaKeywords = "kiem tien tren mang, kiem tien online, viec lam online";
            $this->metaDescription = "Wap Site Tai Game Mobile, Tai Ung dung , Tai Clip Hot nhat Viet Nam";
            
            $currentPage = isset($_GET["page"]) ? intval($_GET["page"]) : 1;
            $currentPage = $currentPage==0 ? 1 : $currentPage;
            $numberRecordPerPage = 6;
            $totalVideoHot = Clip::getTotalVideoHot();
            $numberPage = ceil($totalVideoHot/$numberRecordPerPage);
            
            $url = Url::createUrl("clip/index");
            $url1 = rtrim($url,"/");
            $url.='/';
            $paging = Paging::show_paging_wap_user($numberPage,$currentPage,$url,$url1);
            $data = Clip::getVideoHot($currentPage,$numberRecordPerPage);
            $category = Clip::getVideoCategory();
            $this->render("index",array("data"=>$data,"paging"=>$paging,"category"=>$category));
        }
        public function actionNew(){
            $this->layout = "clip"; 
            $this->linkCanoncical = Url::createUrl('home/new');
            $this->metaTitle = "Kiem tien tren mang, kiem tien that tren mang, viec lam online";
            $this->metaKeywords = "kiem tien tren mang, kiem tien online, viec lam online";
            $this->metaDescription = "Wap Site Tai Game Mobile, Tai Ung dung , Tai Clip Hot nhat Viet Nam";

            $currentPage = isset($_GET["page"]) ? intval($_GET["page"]) : 1;
            $currentPage = $currentPage==0 ? 1 : $currentPage;
            $numberRecordPerPage = 6;
            $totalVideo = Clip::getTotalVideo();
            $numberPage = ceil($totalVideo/$numberRecordPerPage);

            $url = Url::createUrl("clip/new");
            $url1 = rtrim($url,"/");
            $url.='/';
            $paging = Paging::show_paging_wap_user($numberPage,$currentPage,$url,$url1);
            $data = Clip::getVideoNew($currentPage,$numberRecordPerPage);
            $category = Clip::getVideoCategory(); 
            $this->render("index",array("data"=>$data,"paging"=>$paging,"category"=>$category));
        }
        public function actionTop(){
            $this->layout = "clip"; 
            $this->linkCanoncical = Url::createUrl('home/top');
            $this->metaTitle = "Kiem tien tren mang, kiem tien that tren mang, viec lam online";
            $this->metaKeywords = "kiem tien tren mang, kiem tien online, viec lam online";
            $this->metaDescription = "Wap Site Tai Game Mobile, Tai Ung dung , Tai Clip Hot nhat Viet Nam";

            $currentPage = isset($_GET["page"]) ? intval($_GET["page"]) : 1;
            $currentPage = $currentPage==0 ? 1 : $currentPage;
            $numberRecordPerPage = 6; 

            $totalVideo = Clip::getTotalVideo(); 
            $numberPage = ceil($totalVideo/$numberRecordPerPage);

            $data= Clip::getVideoTop($currentPage,$numberRecordPerPage);
            $url = Url::createUrl("clip/top");
            $url1 = rtrim($url,"/");
            $url.='/';
            $paging = Paging::show_paging_wap_user($numberPage,$currentPage,$url,$url1);
            $category = Clip::getVideoCategory(); 
            $this->render("index",array("data"=>$data,'paging'=>$paging,"category"=>$category));
        }
        public function actionCategory(){
            $this->layout = "clip"; 
            $this->linkCanoncical = Url::createUrl('home/top');
            $this->metaTitle = "Kiem tien tren mang, kiem tien that tren mang, viec lam online";
            $this->metaKeywords = "kiem tien tren mang, kiem tien online, viec lam online";
            $this->metaDescription = "Wap Site Tai Game Mobile, Tai Ung dung , Tai Clip Hot nhat Viet Nam";
           
            $catId = isset($_GET['catId'])? intval($_GET['catId']) : 10;
            $alias = isset($_GET['alias'])? $_GET['alias'] : '';
            
            $currentPage = isset($_GET["page"]) ? intval($_GET["page"]) : 1;
            $currentPage = $currentPage==0 ? 1 : $currentPage;
            $numberRecordPerPage = 6;
            
            $totalVideo = Clip::getTotalVideoByCat($catId); 
            $numberPage = ceil($totalVideo/$numberRecordPerPage);

            $data= Clip::getVideoByCat($catId,$currentPage,$numberRecordPerPage);
            $url = Url::createUrl("clip/category",array("catId"=>$catId,"alias"=>$alias));
            $url1 = rtrim($url,"/");
            $url.='/';
            $paging = Paging::show_paging_wap_user($numberPage,$currentPage,$url,$url1);
            $category = Clip::getVideoCategory(); 
            $this->render("index",array("data"=>$data,"paging"=>$paging,"category"=>$category)); 
        }
        public function actionDetail(){
            $this->layout = "clip";    
            $this->linkCanoncical = Url::createUrl('clip/detail');
            $this->metaTitle = "Kiem tien tren mang, kiem tien that tren mang, viec lam online";
            $this->metaKeywords = "kiem tien tren mang, kiem tien online, viec lam online";
            $this->metaDescription = "Wap Site Tai Game Mobile, Tai Ung dung , Tai Clip Hot nhat Viet Nam";
            $this->breadcrumbs[] = array('name'=>'Ứng dụng','link'=>'#','class'=>'active'); 
            $id = isset($_GET['id']) ? intval($_GET['id']) : 0;
            if($id==0){
                $this->redirect("clip/index") ;
            }
            $catId = Clip::getCategoryIdByVideoId($id) ;
            $data_detail = Clip::getInfoVideo($id) ;
            $data_random = clip::getVideoRandomByCatId($catId);
            $category = Clip::getVideoCategory();
            $category_detail = Clip::getVideoCategoryDetail($catId) ;
            $this->render("detail",array("data_detail"=>$data_detail,"data_random"=>$data_random,"category"=>$category,"category_detail"=>$category_detail));
        }
    }
?>
